/* ================================================================================
//	Crypteviant!
//	Providing tough encrypted P2P Chat
//	Copyright (C) 2010  Martin Pfeifer, Tobias Rausch
//
//	This program is free software: you can redistribute it and/or modify
//	it under the terms of the GNU General Public License as published by
//	the Free Software Foundation, either version 3 of the License, or
//	(at your option) any later version.
//
//	This program is distributed in the hope that it will be useful,
//	but WITHOUT ANY WARRANTY; without even the implied warranty of
//	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//	GNU General Public License for more details.
//
//	You should have received a copy of the GNU General Public License
//	along with this program.  If not, see <http://www.gnu.org/licenses/>.
// ============================================================================== */

#ifndef ABSTRACTHASH_HPP
#define ABSTRACTHASH_HPP

#include <QtCore/QString>


namespace Hash { // Namespace Hash


    /**
     * @brief Abstract Interface Class for Hashsum Generators
     * @details This class should be the Interface class for any hashsum implementations.\n
     * It defines all needed functions.
     *
     * @class AbstractHash abstracthash.hpp "abstracthash.hpp"
    */
    class AbstractHash
    {
    public:
        /**
         * @brief Default Constructor
         * @details Current implementation does nothing.
         *
         * @fn AbstractHash
        */
        AbstractHash();


        /**
         * @brief Default Destructor
         * @details Current implemenatation does nothing.
         *
         * @fn ~AbstractHash()
        */
        virtual ~AbstractHash();

        /**
         * @brief Perform incremental update on the internal data
         * @details The data will be appended to an internal storage. The hash of the complete data set
         * will be created with a call to @ref hash() . It may also be possible that this function is
         * implemented using incremental hashing functions.
         *
         * @fn update
         * @param data(const QString)
        */
        virtual void update(const QString data) = 0;

        /**
         * @brief Calculate the hash of the data
         * @details The complete internal buffer will be hashed. It is cleared afterwards.
         *
         * @fn hash()
         * @return QString
        */
        virtual QString hash() = 0;

        /**
         * @brief Generate a hash of the given data
         * @details Something like a static function. This function bypasses the internal data buffer
         * and returns immediately the hashsum of given data. It does not depend on anything stored
         * inside the internal data buffer.\n
         * The output String will be encoded in hexadecimal values.
         *
         * @fn generateHash(QString)
         * @param data
         * @return QString
        */
        virtual QString generateHash(QString &data) const = 0;

        /**
         * @brief Reset internal data to null.
         * @details The internal buffer will be cleared.
         *
         * @fn reset()
        */
        virtual void reset() = 0;
    };
} // End of Namespace Hash

#endif // ABSTRACTHASH_HPP
